#!/opt/php/bin/php
<?php
require_once('TVB/Message/MessageHelper.php');
class PortalSend
{
    private $_type;
    private $_dataArray;

    public function __construct($type)
    {
        $this->_type = $type ? $type : 'programme';
    }

    public function init()
    {
        $data['p_programme'] = array(
            'action' => 'unpublish', 
            'p_programme' => array(
                array(
                    'id' => '88',
					'path' => '_donald_p_test_',
					'primary_category_id' => '',
					'category_list' => '',
					'first_network_codes' => '',
					'first_episode_time_onair' => '',
					'last_episode_time_onair' => '',
					'meta_keywords' => '',
					'meta_description' => '',
					'online_time' => '',
					'offline_time' => '',
					'created_at' => '',
					'modified_at' => '',
					'number_of_episodes' => '',
					'minisite_url' => '',
					'blog_url' => '',
					'forum_id' => '',
					'casts' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'description' => '',
					'description_zh' => '',
					'description_en' => '',
					'description_short' => '',
					'description_short_zh' => '',
					'description_short_en' => '',
					'first_onair_information' => '',
					'first_onair_information_zh' => '',
					'first_onair_information_en' => '',
					'tags' => '',
					'nominal_duration' => '',
					'banner_image' => '',
					'key_art_image' => '',
					'first_time_onair' => '',
					'objective' => '',
					'starting_episode_no' => '',
					'production_start_date' => '',
					'fact_background' => '',
					'fact_background_zh' => '',
					'fact_background_en' => '',
					'mytv_view' => '',
					'mytv_plus_view' => '',
					'total_view' => '',
					'mytv_fav' => '',
					'mytv_plus_fav' => '',
					'total_fav' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_episode'] = array(
            'action' => 'unpublish',
            'p_episode' => array(
                array(
                    'id' => '250',
					'programme_id' => '88',
					'onair_episode_no' => '',
					'first_time_onair' => '',
					'other_language_episodes' => '',
					'online_time' => '',
					'offline_time' => '',
					'created_at' => '',
					'modified_at' => '',
					'casts' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'description' => '',
					'description_zh' => '',
					'description_en' => '',
					'description_short' => '',
					'description_short_zh' => '',
					'description_short_en' => '',
					'editor_message' => '',
					'editor_message_zh' => '',
					'editor_message_en' => '',
					'rates' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_cast'] = array(
            'action' => 'publish',
            'p_cast' => array(
                array(
                    'id' => '490',
					'programme_id' => '88',
					'cast_role_id' => '',
					'created_at' => '',
					'modified_at' => '',
					'gender' => '',
					'age' => '',
					'blog_url' => '',
					'real_first_name' => '',
					'real_first_name_zh' => '',
					'real_first_name_en' => '',
					'real_last_name' => '',
					'real_last_name_zh' => '',
					'real_last_name_en' => '',
					'real_name' => '',
					'real_name_zh' => '',
					'real_name_en' => '',
					'other_name' => '',
					'other_name_zh' => '',
					'other_name_en' => '',
					'nickname' => '',
					'nickname_zh' => '',
					'nickname_en' => '',
					'occupation' => '',
					'occupation_zh' => '',
					'occupation_en' => '',
					'personality' => '',
					'personality_zh' => '',
					'personality_en' => '',
					'profile' => '',
					'profile_zh' => '',
					'profile_en' => '',
					'history' => '',
					'history_zh' => '',
					'history_en' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_chapter'] = array(
            'action' => 'publish',
            'p_chapter' => array(
                array(
                    'id' => '162',
					'programme_id' => '88',
					'episode_id' => '250',
					'onair_episode_no' => '',
					'video_id' => '',
					'in_time' => '',
					'out_time' => '',
					'primary_category_id' => '',
					'created_at' => '',
					'modified_at' => '',
					'tags' => '',
					'ii_data' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'description' => '',
					'description_zh' => '',
					'description_en' => '',
					'casts' => '',
					'categories' => '',
					'infos' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_folder_image'] = array(
            'action' => 'publish',
            'p_folder_image' => array(
                array(
                    'folder_id' => '1798',
					'folder_type_path' => '',
					'image_id' => '179',
					'rank' => '',
					'programme_id' => '',
					'episode_id' => '',
					'onair_episode_no' => '',
					'folder_list' => '',
					'online_time' => '',
					'offline_time' => '',
					'country_allow_list' => '',
					'country_deny_list' => '',
					'created_at' => '',
					'modified_at' => '',
					'tags' => '',
					'ii_data' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_folder'] = array(
            'action' => 'publish',
            'p_folder' => array(
                array(
                    'id' => '1798',
					'folder_type_path' => '',
					'programme_id' => '88',
					'episode_id' => '',
					'onair_episode_no' => '',
					'cast_id' => '',
					'created_at' => '',
					'modified_at' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'contains' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_folder_video'] = array(
            'action' => 'publish',
            'p_folder_video' => array(
                array(
                    'folder_id' => '1803',
					'folder_type_path' => '',
					'video_id' => '228',
					'rank' => '',
					'programme_id' => '88',
					'episode_id' => '',
					'onair_episode_no' => '',
					'created_at' => '',
					'modified_at' => '',
					'online_time' => '',
					'offline_time' => '',
					'country_allow_list' => '',
					'country_deny_list' => '',
					'first_time_onair' => '',
					'tags' => '',
					'vi_data' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_image'] = array(
            'action' => 'publish',
            'p_image' => array(
                array(
                    'id' => '88',
					'programme_id' => '88',
					'episode_id' => '250',
					'onair_episode_no' => '',
					'folder_list' => '',
					'online_time' => '',
					'offline_time' => '',
					'country_allow_list' => '',
					'country_deny_list' => '',
					'created_at' => '',
					'modified_at' => '',
					'tags' => '',
					'ii_data' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $data['p_info'] = array(
            'action' => 'publish',
            'p_info' => array(
                array(
                    'info_id' => '88',
					'info_type_id' => '1',
					'programme_id' => '88',
					'episode_id' => '250',
					'onair_episode_no' => '',
					'video_id' => '',
					'chapter_id' => '',
					'online_time' => '',
					'offline_time' => '',
					'created_at' => '',
					'modified_at' => '',
					'title' => '',
					'description' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );

        $data['p_video'] = array(
            'action' => 'publish',
            'p_video' => array(
                array(
                    'id' => '88',
					'programme_id' => '88',
					'episode_id' => '250',
					'onair_episode_no' => '',
					'folder_list' => '',
					'online_time' => '',
					'offline_time' => '',
					'country_allow_list' => '',
					'country_deny_list' => '',
					'created_at' => '',
					'modified_at' => '',
					'first_time_onair' => '',
					'ii_data' => '',
					'vi_data' => '',
					'source_id' => '',
					'title' => '',
					'title_zh' => '',
					'title_en' => '',
					'breakpoint' => '',
					'duration' => '',
					'tags' => '',
					'other_videos' => '',
					'mytv_view' => '',
					'mytv_plus_view' => '',
					'total_view' => '',
					'mytv_fav' => '',
					'mytv_plus_fav' => '',
					'total_fav' => '',
					'video_type' => '',
					'premium_title' => '',
					'premium_title_zh' => '',
					'premium_title_en' => '',
					'ppv_flag' => '',
					'ppv_online_time' => '',
					'ppv_offline_time' => '',
					'ppv_country_allow_list' => '',
					'ppv_country_deny_list' => '',
					'subscription_flag' => '',
					'subscription_free_flag' => '',
					'subscription_online_time' => '',
					'subscription_offline_time' => '',
					'subscription_country_allow_list' => '',
					'subscription_country_deny_list' => '',
                ),
            ),
        );
        $this->_dataArray = $data[$this->_type];
    }

    public function sendDataToPortal()
    {
        $broker = 'failover://(tcp://vm043.dev.hk3.tvb.com:61613,tcp://vm043.dev.hk3.tvb.com:61613)?randomize=false';
        $queue = '/queue/Portal.P_PortalService';
        MessageHelper::sendMessage($broker, $queue, $this->_dataArray);
    }
}
$type = isset($argv[1]) ? $argv[1] : 'programme';
$portal = new PortalSend($type);
$portal->init();
$portal->sendDataToPortal();
?>
